package com.itheima.tliaswebmanagement.mapper;

import com.github.pagehelper.Page;
import com.itheima.tliaswebmanagement.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    Page<Student> list(Student student);

    @Delete("delete from student where id=#{id}")
    void deleteById(Integer ids);

    @Insert("insert into student (name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id, create_time, update_time)" +
            "values (#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void save(Student student);

    @Select("select * from student where id= #{id}")
    Student getById(Integer id);

    void update(Student student);

    @Update("update student set violation_score=violation_score+#{score},violation_count=violation_count+1 where id=#{id}")
    void violation(Integer id, Integer score);

    @MapKey("class")
    List<Map<String, Object>> countCountData();

    @MapKey("degree")
    List<Map<String, Object>> countDegreeData();
}
